11. Pass Through Filtering
Pass Through Filtering
If you have some prior information about the location of your target in the scene, you can apply a Pass Through Filter to remove useless data from your point cloud.
The Pass Through Filter works much like a cropping tool, which allows you to crop any given 3D point cloud by specifying an axis with cut-off values along that axis. The region you allow to pass through, is often referred to as region of interest.
For instance, in our tabletop scene we know that the table is roughly in the center of our robot’s field of view. Hence by using a Pass Through Filter we can select a region of interest to remove some of the excess data.
Applying a Pass Through filter along z axis (the height with respect to the ground) to our tabletop scene in the range 0.1 to 0.8 gives the following result:
Oops! We've retained the table but filtered out all of the objects!
Your next task is to apply a Pass Through Filter to the point cloud of the tabletop scene such that you retain only the tabletop and the objects sitting on the table. When you're successful the result should look similar to this:
To accomplish this task, add the following code to your RANSAC.py
file in the Pass Through Filter section to select a region of interest from your Voxel Downsample Filtered point cloud.
# PassThrough filter
# Create a PassThrough filter object.
passthrough = cloud_filtered.make_passthrough_filter()
# Assign axis and range to the passthrough filter object.
filter_axis = 'z'
passthrough.set_filter_field_name(filter_axis)
axis_min = 0
axis_max = 2
passthrough.set_filter_limits(axis_min, axis_max)
# Finally use the filter function to obtain the resultant point cloud.
cloud_filtered = passthrough.filter()
filename = 'pass_through_filtered.pcd'
pcl.save(cloud_filtered, filename)
Investigate your result using pcl_viewer
.
Pass Through Filter